package Modelo.ObjetosDAO;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;

import Modelo.Rol;
import Modelo.GestionDeBD.GestorBD;

public class RolDAO implements IRolDAO {
	private GestorBD gbd = GestorBD.getGestorBD();
	
	public Vector<Rol> cargarRoles(){
		Connection conn = gbd.getConnection();
		Vector<Rol> listaRoles = new Vector<Rol>();
		PreparedStatement sentencia = null;
		ResultSet rs = null;

		try {
			String consulta = "SELECT * FROM rol";
			sentencia = conn.prepareStatement(consulta);
			rs = sentencia.executeQuery();
			while (rs.next()) {
				Rol rol = new Rol(rs.getString("descripcion"), rs.getInt("id"));
				listaRoles.add(rol);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return listaRoles;
	}
	
}
